//index.js

const http = require("../../models/https")

//获取应用实例
const app = getApp()
Page({
  data: {
    value:[]
  },
  onLoad: function () {
    http({
      url:"http://47.113.104.50:8000/cart",
      success:res=>{
        this.setData({
          value:res.data
        })
        console.log(this.data.value);
      }
    })
  },
  onStep(event){
    console.log(event.detail);
    this.data.value.forEach(res=>{
      if(res.id==event.currentTarget.dataset.id){
        res.productCount = event.detail
      }
    })
    this.setData({
      value:this.data.value
    })
  },
  onChange(event){
    this.data.value.forEach(res=>{
      if(res.id==event.currentTarget.dataset.id){
        res.isSelected = event.detail
      }
    })
    this.setData({
      value:this.data.value
    })
  },
  onSum(event){
    this.data.value.forEach(res=>{
      res.isSelected = event.detail
    })
    this.setData({
      value:this.data.value
    })
  }
})
